hardDelete function not workin in eval_ call

I am having a problem running the hardDelete function inside the string code ran by an eval_ function. The hardDelete function (and delete function) for deleting objects causes DOORS to crash with a C++ error talking about a "pure virtual function call". The script works if hardDelete is substituted with softDelete. Doors is stupid. Can someone please help, the code is attached.

 

Thanks


JohnEarnshaw - Fri Aug 21 17:11:21 EDT 2015

Re: hardDelete function not workin in eval_ call
llandale - Tue Sep 01 14:27:07 EDT 2015

Don't know.

But I will say you cannot "hardDelete" an object unless it and all its descendants are NOT deleted.  You cannot "hardDelete" a "softDelete"d object; go figure.  You need to undelete it first.

I see you ignore deleted objects (in your treeCleaner); well that means you will be trying to hardDelete some undeleted objects that have deleted descendants.

IIRC, this you CAN attempt to softDelete a deleted object.  Of so, this excplains why hardDelete doesn't work but softDelete does; although I don't know why you would get a "pure virtual function call" error.

  • Your treeCleaner() seems to be odd.  It selectively deletes leaf objects under the original object; but (in deleteFunction()) only actually deletes those objects that do not say "yes"; implying other objects are not deleted.  But treeCleaner() tries to hardDelete all objects in the module.
  • I think you should remove the isDeleted(oFN2) check in treeCleaner(); and in deleteFunction above your hardDelete(o); undelete the object if it is deleted.
  • I'm guessing here, but I suspect deleteFunction() should not attempt to delete a "non-yes" object unless it is a leaf; reporting some error if so.
  • I'm worried about your two Object loops that delete the loop object. (for oFN2 in oFN do; and for oDoc in all mCode do).  The loop variable may or may not be nulled out by the time the loop goes to the top again.  It is far better to store the objects in a Skip list; then iterate the skip list deleting its objects.
  • Since treeCleaner() recurses, I think your "all" loop should be a "top" loop.

-Louie

You really should add comments, although your near perfect indentation helps a lot.  Two statements need one level less indentation: [1] string sCode = " and [2] eval_ sCode); and the end of sCode needs desperately to be noted in a comment.